package com.yxw.job.feign.fallback;

import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import com.yxw.job.feign.client.CustomServiceFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class CustomServiceFallbackFactory implements FallbackFactory<CustomServiceFeignClient> {


    @Override
    public CustomServiceFeignClient create(Throwable cause) {
        return new CustomServiceFeignClient() {
            @Override
            public BaseResult insertChannelStatistics() {
                return new BaseResult<>("9999", "渠道活跃统计服务熔断，熔断原因：" + cause.getMessage());
            }

            @Override
            public BaseResult insertStandStatistics() {
                return new BaseResult<>("9999", "客服维护统计服务熔断，熔断原因：" + cause.getMessage());
            }

            @Override
            public BaseResult execChatStatistics() {
                log.error("抽取客服接待客户数统计（群维度）错误：" + cause.getMessage());
                return new BaseResult<>("9999", "抽取客服接待客户数统计（群维度）错误：" + cause.getMessage());
            }
        };
    }
}
